package com.yookey.common.utils;

import org.springframework.util.DigestUtils;

import java.io.UnsupportedEncodingException;

/**
 * MD5工具类
 *
 */
public class MD5Util {
    //盐，用于混交md5
    private static final String slat = "&%5123***&&%%$$#@a";
    /**
     * 生成md5
     * @param str
     * @return
     */
    public static String getMD5(String str) {
        String base = str +"/"+slat;
        String md5 = null;
        try {
            md5 = DigestUtils.md5DigestAsHex(base.getBytes("UTF8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return md5;
    }



    public static void main(String []args){
        System.out.println(getMD5("13579"));
        System.out.println(getMD5("12345678"));
        System.out.println(getMD5("123456"));
        System.out.println(getMD5("1234"));
        System.out.println(getMD5("123"));
    }
}